<?php echo $header; ?>
<div id="content">
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <?php if ($error_warning) { ?>
    <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
    <div class="box">
        <div class="heading">
            <h1><img src="view/image/shipping.png" alt="" /> <?php echo $heading_title; ?></h1>
            <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a href="<?php echo $cancel; ?>" class="button"><?php echo $button_cancel; ?></a></div>
        </div>
        <div class="content">
            <div id="tabs" class="htabs">
                <a href="#tab-general"><?php echo $tab_general; ?></a>
                <a href="#tab-address"><?php echo $tab_address; ?></a>
            </div>
            <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
                <div id="tab-general">
                    <table class="form">
                        <tr>
                            <td><span class="required">*</span> <?php echo $entry_short_name; ?></td>
                            <td><input type="text" name="short_name" value="<?php echo $short_name; ?>" size="25" maxlength="25" />
                                <?php if ($error_short_name) { ?>
                                <span class="error"><?php echo $error_short_name; ?></span>
                                <?php } ?></td>
                        </tr>
                        <tr>
                            <td><span class="required">*</span> <?php echo $entry_name; ?></td>
                            <td><input type="text" name="name" value="<?php echo $name; ?>" size="150" />
                                <?php if ($error_name) { ?>
                                <span class="error"><?php echo $error_name; ?></span>
                                <?php } ?></td>
                        </tr>
                        <tr>
                            <td><span class="required">*</span> <?php echo $entry_address; ?></td>
                            <td><input type="text" name="address" size="150" value="<?php echo $address; ?>" />
                                <?php if ($error_address) { ?>
                                <span class="error"><?php echo $error_address; ?></span>
                                <?php } ?></td>
                        </tr>
                        <tr>
                            <td><?php echo $entry_tax_code; ?></td>
                            <td><input type="text" name="tax_code" value="<?php echo $tax_code; ?>" size="10" />
                            </td>
                        </tr>
                        <tr>
                            <td><?php echo $entry_sort_order; ?></td>
                            <td><input type="text" name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
                        </tr>
                    </table>
                </div>
                <div id="tab-address">
                    <table class="list" id="supplier-address">
                        <thead>
                            <tr>
                                <td class="left"><?php echo $entry_name; ?></td>
                                <td class="left"><?php echo $entry_address; ?></td>
                                <td>&nbsp;</td>
                            </tr>
                        </thead>
                        
                        <?php $address_row = 0; ?>
                        <?php if($address_secons){ ?>
                        <?php foreach ($address_secons as $address_secon) { ?>
                        <tbody id="address-row<?php echo $address_row; ?>">
                            <tr>
                                <td class="left"><input type="text" name="address_secons[<?php echo $address_row; ?>][name]" value="<?php echo $address_secon['name']; ?>" size="25" /></td>
                                <td class="left"><input type="text" name="address_secons[<?php echo $address_row; ?>][address_supplier]" value="<?php echo $address_secon['address']; ?>" size="100" /></td>
                                <td class="left"><a onclick="$('#address-row<?php echo $address_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
                            </tr>
                        </tbody>
                        <?php $address_row++; ?>
                        <?php } ?>
                        <?php } ?>
                        <tfoot>
                            <tr>
                                <td colspan="2"></td>
                                <td class="left"><a onclick="addAddress();" class="button"><?php echo $button_add_address; ?></a></td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript"><!--
$('#tabs a').tabs();
//--></script> 
<script type="text/javascript"><!--
var address_row = <?php echo $address_row; ?>;
function addAddress() {
    html = '<tbody id="address-row' + address_row + '">';
    html += '<tr>';
    html += '<td class="left"><input type="text" name="address_secons[' + address_row + '][name]" value="" size="25" /></td>';
    html += '<td class="left"><input type="text" name="address_secons[' + address_row + '][address_supplier]" value="" size="100" /></td>';
    html += '<td class="left"><a onclick="$(\'#address-row' + address_row + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
    html += '</tr>';
    html += '</tbody>';

    $('#supplier-address tfoot').before(html);

    address_row++;
}
//--></script> 
<?php echo $footer; ?>